import { _decorator, Component, Node, Socket } from 'cc';
const { ccclass } = _decorator;

@ccclass('socketTest')
export class socketTest extends Component {
	socket=null
    start() {
		  this.socket = io.connect('http://localhost:3000')
      this.socket.on('connect',(data)=>{
        console.log('链接成功');
        
        //客户端发消息
        this.socket.emit('message','helo ')
        //客户端接收消息
        this.socket.on('message',(data)=>{
          console.log(data);
          
        })
      })
      this.socket.on('disconnect',()=>{
        console.debug('断开链接')
      })
    }

    update(deltaTime: number) {
        
    }
}

